// 与评论相关的请求
// 一、导入axios
import axios from '@/utils/request'

// 二、导出方法
// 1.1 获取评论
export function getComments(articleId, offset) {
  return axios({
    method: 'get',
    url: '/v1_0/comments',
    params: {
      type: 'a',
      source: articleId,
      offset,
    },
  })
}

// 1.2 发布评论
export function postComments(articleId, content) {
  return axios({
    method: 'post',
    url: '/v1_0/comments',
    data: {
      target: articleId,
      content,
    },
  })
}

// 1.3 评论点赞
export function postLikings(commentId) {
  return axios({
    method: 'post',
    url: '/v1_0/comment/likings',
    data: { target: commentId },
  })
}
// 1.4 取消评论点赞
export function delLikings(commentId) {
  return axios({
    method: 'delete',
    url: `/v1_0/comment/likings/${commentId}`,
  })
}

// 1.5 获取评论回复
export function getCommentsReply(comId, offset) {
  return axios({
    method: 'get',
    url: '/v1_0/comments',
    params: {
      type: 'c',
      source: comId,
      offset,
    },
  })
}

// 1.6 对评论进行发布评论回复
export function postCommentsReply(comId, content, articleId) {
  return axios({
    method: 'post',
    url: '/v1_0/comments',
    data: {
      target: comId,
      content,
      art_id: articleId,
    },
  })
}
